﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Api.Filter;
using Customer.Bussiness_Service;
using Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ServiceCore;

namespace Customer.Areas.System.Controllers
{

    [ApiController, Area("System"), Route("/user/[action]")]
    public class userController : ControllerBase
    {
        private readonly Iuser_service _service; 
        private readonly IToole_DI _tool;
        public userController(Iuser_service service, IToole_DI tool)
        {
            _service = service;
            _tool = tool;
        }
        /// <summary>
        /// 获取角色列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultListModel<rk_user_search> get_pagelist(Base_List_Params query)
        {
            var result = _service.get_pagelist(query);
            return result;
        }
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel save_item(rk_user model)
        {
            _tool.di_es.Add_Log("=====添加用户====" + Newtonsoft.Json.JsonConvert.SerializeObject(model), "/API_User");
            var result = _service.save_item(model);
            _tool.di_es.Add_Log("=====添加用户====" + Newtonsoft.Json.JsonConvert.SerializeObject(result), "/API_User");
            return result;
        }
        [HttpGet]
        public ResultModel set_wx_bind(string uid, string openid, string unionid, string wx_name, string headimg)
        {

            var result = _service.set_wx_bind(uid, openid, unionid, wx_name, headimg);
            return result;
        }
        [HttpGet]
        public ResultModel set_wx_unbind(string uid,string openid)
        {
            var result = _service.set_wx_unbind(uid, openid);
            return result;
        }
        [HttpGet]
        public ResultModel change_pwd(string newpwd)
        {
            var result = _service.change_pwd(newpwd);
            return result;
        }


        [HttpGet]
        public ResultModel change_pwd_web(string newpwd,string oldpwd)
        {
            var result = _service.change_pwd_web(oldpwd, newpwd);
            return result;
        }

    }
}